package com.jch.dm.chapter_23_interpreter;

/**
 * @author: Administrator
 * <repeat command> ::= repeat <number> <command list>
 * @create: 2020/04/14 18:25
 **/
public class RepeatCommandNode extends Node {
    private int number;
    private Node commandListNode;

    /**
     * 解析
     *
     * @param context
     * @throws ParseException
     */
    @Override
    public void parse(Context context) throws ParseException {
        context.skipToken("repeat");
        number = context.currentNumber();
        context.nextToken();
        commandListNode = new CommandListNode();
        commandListNode.parse(context);
    }

    @Override
    public String toString() {
        return "[repeat " + number + " " + commandListNode + "]";
    }
}

